﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ORMAC.Attributes;


namespace ORMAC.CodeGen
{
    [SQL(Query = "SELECT * FROM sys.objects WHERE objectproperty(object_id, N'IsMSShipped') = 0     AND objectproperty(object_id, N'IsProcedure') = 1 ")]
    public class SProcInfo : DBObjectInfo
    {
        [PrimaryKey]
        [Field("object_id")]
        public int ObjectID { get; set; }
        /// <summary>
        /// List of table columns
        /// </summary>
        [Join(ParentCol = "object_id", ChildCol = "object_id")]
        public List<ParameterInfo> Params { get; set; }
        /// <summary>
        /// return columns from sproc
        /// </summary>
        [ORMAC(AutoLoad = false)]
        public List<ReturnInfo> ReturnColumns { get; set; }
        /// <summary>
        /// the class information of the returned type
        /// </summary>
        [ORMAC(AutoLoad=false)]
        public TableInfo ReturnClass { get; set; }
        [ORMAC(AutoLoad = false)]
        public string returnTypeName
        {
            get
            {
                if (ReturnClass != null)
                    return new Settings().ClassPrefix+ ReturnClass.CodeName;
                else
                    return "void";
            }
        }
    }
}
